import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters' 
Vue.use(Vuex)
//读取当前目录下的所有js 类似import xxx from xxx
const modulesFiles = require.context('./modules', true, /\.js$/);

 //自动导入./modules目录下的vuex模块
 const modules = modulesFiles.keys().reduce((modules, modulePath) => {
   // set './app.js' => 'app'
   const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
   const value = modulesFiles(modulePath)
   modules[moduleName] = value.default
   return modules
 }, {})
 const store = new Vuex.Store({
   modules,
   getters
 })
 export default store
